const handleChartData = (headerData, data) => {
  let legendData = []
  let xAxisData = []
  let seriesData = []
  for (let i = 0; i < data.length; i++) {
    // 初始化柱图数据
    legendData.push(data[i].lineName)
    let obj = {
      name: data[i].lineName,
      type: 'bar',
      data: []
    }
    obj.data.push(data[i]['payNumber'])
    obj.data.push(data[i]['busCount'])
    obj.data.push(data[i]['avg'])
    seriesData.push(obj)
  }
  for (let i = 0; i < headerData.length; i++) {
    if (headerData[i].name !== 'lineName' && headerData[i].name !== 'standardTime') {
      xAxisData.push(headerData[i].label)
    }
  }
  return {legendData, xAxisData, seriesData}
}

export default handleChartData
